<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiLinksLinksTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_links_links';

    /**
     * Run the migrations.
     * @table qii_links_links
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'MyISAM';
            $table->increments('id')->comment('ID');
            $table->string('title', 50)->default('')->comment('标题');
            $table->unsignedInteger('title_crc32')->default('0')->comment('标题的循环冗余校验码(用于提高检索性能)');
            $table->string('links', 50)->default('')->comment('链接');
            $table->integer('category_id')->default('1')->comment('类别ID(暂时无用)');
            $table->integer('site_id')->default('0')->comment('站点ID');
            $table->integer('lang_id')->default('0')->comment('语言版本ID(暂时无用)');
            $table->integer('status_id')->default('1')->comment('状态ID (0已禁用,1正常)');
            $table->integer('modified')->default('0')->comment('添加/修改时间');
            $table->integer('num')->default('0')->comment('频率');

            $table->index(["category_id", "status_id", "title_crc32"], 'title_crc32');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
